#define _CRT_SECURE_NO_WARNINGS
#include "ModelSettings.h"
string ModelSettings::GetInputDirectory(string fileName)
{
	char homeDirect[1024];
	_getcwd(homeDirect, 1024);
	string localDirect = (string)(homeDirect)+(string)("\\LocalSettings\\") + fileName;
	return localDirect;
}
ModelSettings::ModelSettings() {
	gVxStart = 0.0;
	gVxEnd = 0.0;
	gVy = 0.0;
	startInjectionYPosition = 0.0;
	endInjectionYPosition = 0.0;
	totalMassFlowRate = 0.0;
	pVx0 = 0.0;
	pVy0 = 0.0;
	pT0 = 0.0;
	pRho = 0.0;
	numberInjectionPosition = 1;
	numberIterationSteps = 1;
	sizeTypes = 0;
	nBins = 1;
	PSD_RR_Dmin = 0.0;
	PSD_RR_Dmax = 0.0;
	PSD_RR_Dmean = 0.0;
	PSD_RR_SP = 0.0;
	PSD_RR_nBins = 0.0;
	vector<double>PSD_User_Dia = vector<double>(nBins, 3.0e-5);
	vector<double>PSD_User_DiaRatio = vector<double>(nBins, 1.0);
}
ModelSettings::ModelSettings(string modelTypes) {
	/* filename variables read in*/
	string localDirect = GetInputDirectory(modelTypes);
	ifstream read_file_modelTypes(localDirect);
	string s1[100];
	assert(read_file_modelTypes.is_open());
	read_file_modelTypes >> s1[0] >> gVxStart;
	read_file_modelTypes >> s1[1] >> gVxEnd;
	read_file_modelTypes >> s1[2] >> gVy;
	read_file_modelTypes >> s1[3] >> startInjectionYPosition;
	read_file_modelTypes >> s1[4] >> endInjectionYPosition;
	read_file_modelTypes >> s1[5] >> totalMassFlowRate;
	read_file_modelTypes >> s1[6] >> pVx0;
	read_file_modelTypes >> s1[7] >> pVy0;
	read_file_modelTypes >> s1[8] >> pT0;
	read_file_modelTypes >> s1[9] >> pRho;
	read_file_modelTypes >> s1[10] >> numberInjectionPosition;
	read_file_modelTypes >> s1[11] >> numberIterationSteps;
	read_file_modelTypes >> s1[12] >> sizeTypes;
	read_file_modelTypes >> s1[13] >> nBins;
	read_file_modelTypes >> s1[14] >> PSD_RR_Dmin;
	read_file_modelTypes >> s1[15] >> PSD_RR_Dmax;
	read_file_modelTypes >> s1[16] >> PSD_RR_Dmean;
	read_file_modelTypes >> s1[17] >> PSD_RR_SP;
	read_file_modelTypes >> s1[18] >> PSD_RR_nBins;
	if (sizeTypes == 0) {
		PSD_User_Dia = vector<double>(nBins, 0.0);
		PSD_User_DiaRatio = vector<double>(nBins, 0.0);
		for (int i = 0; i < nBins; i++)
		{
			read_file_modelTypes >> s1[19 + i] >> PSD_User_Dia[i];
		}
		for (int i = 0; i < nBins; i++)
		{
			read_file_modelTypes >> s1[19 + nBins + i] >> PSD_User_DiaRatio[i];
		}
	}
	else {
		PSD_User_Dia = vector<double>(1, 0.0);
		PSD_User_DiaRatio = vector<double>(1, 0.0);
	}
	read_file_modelTypes.close();
}
